package com.strive.village.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.strive.village.entity.SysRole;
import com.strive.village.mapper.SysRoleMapper;
import com.strive.village.service.SysRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务实现类
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {

    /**
     * 根据用户ID获取用户角色信息
     *
     * @param userId
     * @return
     */
    @Override
    public List<SysRole> listRolesByUserId(Long userId) {
        List<SysRole> sysRoles = this.list(new QueryWrapper<SysRole>().inSql("id", "select role_id from sys_user_role where user_id = " + userId));
        return sysRoles;
    }
}
